package ctaModel;

import good.YearConverter;

import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Iterator;

import BookModel.Book;
import BookModel.Inventory;
import BookModel.Year;
import au.com.bytecode.opencsv.CSVReader;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

import converters.IdConverter;

public class TestCta {
	
	public static void main(String[] args) throws FileNotFoundException,
	IOException {

	final String CSV_FILE = "testcta.csv";
	CSVReader reader = new CSVReader(new FileReader(CSV_FILE));
	String[] nextLine;
	Banner banner = new Banner();
	XStream xStream = new XStream(new DomDriver());
	
	while ((nextLine = reader.readNext()) != null) {
	
		Item item = new Item();
		item.setId(new Id(nextLine[0]));
		
		banner.addItem(item);
	
		xStream.alias("banner", Banner.class);
		xStream.alias("item", Item.class);
		xStream.useAttributeFor(Item.class, "id");
		xStream.registerConverter(new IdConverter());
		xStream.addImplicitCollection(Banner.class, "item");
	

	}
	System.out.println(xStream.toXML(banner));
	}
}
